// xc_lshop/savemoney/recharge/com/phone.js
Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    config:Object
  },
  

  /**
   * 组件的初始数据
   */
  data: {
    keyval:"",
    nav:[
      {name:"移动",key:"1",disabled:1},
      {name:"联通",key:"2",disabled:1},
      {name:"电信",key:"3",disabled:1},
 
    ],
    phone:"",
    itemindex:-1,
    checked:false
  },
  ready(){
  
    var that=this
    setTimeout( function(){
      var newnav= that.data.nav
      if(that.data.config && that.data.config.type){
        var type=that.data.config.type
         for(var i in type){
           newnav[type[i]-1].disabled=-1
         }
      }
      that.setData({
        nav:newnav
      })
      
      }, 500 );
   

 },
  /**
   * 组件的方法列表
   */
  methods: {
    onClickNav(e){
      var dataset=e.currentTarget.dataset;
      if(dataset.disabled==-1){
        this.setData({
          keyval:dataset.val
        })
        this.chuanzhi("type",e.currentTarget.dataset.val)
      }
     
    },
    inputtext(e){
     

      this.chuanzhi("number",e.detail)
    },
    // onChange(e){
    //   console.log("onChange")
    //   console.log(e)
    //   var val=!this.data.checked
    //   this.setData({
    //     checked:val
    //   })
    //   this.chuanzhi("ischecked",val)
      
    // },
    choosePrice(e){
      var dataset=e.currentTarget.dataset;
      this.setData({
        itemindex:dataset.index
      })
      this.chuanzhi("item",dataset.item)
    },
    chuanzhi(name,data){
      var data={
        name:name,
        data:data
      }
      this.triggerEvent('chuanzhi', data, {})
    }
  }
})
